Skip to content

Add Beholder default metric filter views#2238

Open
pkcll wants to merge 4 commits into
beholder-otel-limit-metric-cardinalityfrom
beholder-otel-metric-filter-views
Open

Add Beholder default metric filter views#2238
pkcll wants to merge 4 commits into
beholder-otel-limit-metric-cardinalityfrom
beholder-otel-metric-filter-views

Conversation

@pkcll

@pkcll pkcll commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add pkg/beholder/metricviews with deny-only DefaultViews(blacklist) — empty blacklist by default (no attributes stripped until configured).
  • Add MetricViewsAttributeBlacklist on beholder.Config, wired via CL_TELEMETRY_METRIC_VIEWS_ATTRIBUTE_BLACKLIST (comma-separated) through loop EnvConfig and server.go.
  • Refactor meter provider helpers to Config.metricViews() and zero-arg Config.metricOptions(); caller views precede defaults so histogram-bucket overrides are not shadowed.
  • Wire CL_TELEMETRY_METRIC_VIEWS_DISABLED as an emergency disable flag.

Stacks on #2225 (cardinality limit). Merge limit PR first, then rebase this onto main.

Test plan

  • go test ./pkg/beholder/... ./pkg/loop

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

✅ API Diff Results - github.com/smartcontractkit/chainlink-common

✅ Compatible Changes (4)

package github (1)
  • com/smartcontractkit/chainlink-common/pkg/beholder/metricviews — ➕ Added
pkg/beholder.Config (1)
  • MetricViewsAttributeDenylist — ➕ Added
pkg/beholder.writerClientConfig (1)
  • MetricViewsAttributeDenylist — ➕ Added
pkg/loop.EnvConfig (1)
  • TelemetryMetricViewsAttributeDenylist — ➕ Added

📄 View full apidiff report

@pkcll pkcll force-pushed the beholder-otel-limit-metric-cardinality branch from 9eaf479 to a7dbabb Compare July 10, 2026 23:14
@pkcll pkcll force-pushed the beholder-otel-metric-filter-views branch 2 times, most recently from ee3c5d6 to ed2bce5 Compare July 11, 2026 00:00
@pkcll pkcll force-pushed the beholder-otel-limit-metric-cardinality branch from 1215879 to a0f879f Compare July 13, 2026 17:47
@pkcll pkcll force-pushed the beholder-otel-metric-filter-views branch from 49139a9 to ff6c540 Compare July 13, 2026 17:48
@pkcll pkcll marked this pull request as ready for review July 13, 2026 18:56
@pkcll pkcll requested review from a team as code owners July 13, 2026 18:56
Comment thread pkg/beholder/config.go Outdated
MetricViewsDisabled bool
// MetricViewsAttributeBlacklist lists attribute keys dropped by the default
// global deny view (e.g. event_id). Empty means no keys are stripped.
MetricViewsAttributeBlacklist []string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ubiquitous language -

Suggested change
MetricViewsAttributeBlacklist []string
MetricViewsAttributeDenylist []string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to MetricViewsAttributeDenylist / CL_TELEMETRY_METRIC_VIEWS_ATTRIBUTE_DENYLIST.

Comment thread pkg/beholder/config.go Outdated
MetricViews []metric.View
// MetricViewsDisabled skips metricviews.DefaultViews() attribute filtering.
// Caller-supplied MetricViews are still applied. Set via CL_TELEMETRY_METRIC_VIEWS_DISABLED.
MetricViewsDisabled bool

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an indirect way to accomplish "skips metricviews.DefaultViews() attribute filtering." could we make this a configurable func instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed MetricViewsDisabled. metricViews() now skips DefaultViews() when len(MetricViewsAttributeDenylist) == 0.

Comment thread pkg/beholder/meter_provider.go Outdated
if cfg.MetricViewsDisabled {
return cfg.MetricViews
}
return append(cfg.MetricViews, metricviews.DefaultViews(cfg.MetricViewsAttributeBlacklist)...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what layer actually enforces the blacklist?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty

@pkcll pkcll force-pushed the beholder-otel-metric-filter-views branch from f9ad01a to c2bb0f6 Compare July 13, 2026 19:41
pkcll and others added 4 commits July 13, 2026 16:00
Introduce metricviews.DefaultViews() with an empty denylist by default,
Config.metricViews/metricOptions methods, and CL_TELEMETRY_METRIC_VIEWS_DISABLED
wiring through loop env and server. Caller views precede defaults so
histogram-bucket overrides are not shadowed.

Co-authored-by: Cursor <cursoragent@cursor.com>
Expose MetricViewsAttributeBlacklist on beholder.Config and wire
CL_TELEMETRY_METRIC_VIEWS_ATTRIBUTE_BLACKLIST through loop env and server.
DefaultViews builds a global deny view when keys are configured.

# Conflicts:
#	pkg/loop/config_test.go
Wire MetricViewsAttributeBlacklist through beholder.Config and
CL_TELEMETRY_METRIC_VIEWS_ATTRIBUTE_BLACKLIST via loop env/server.
DefaultViews(blacklist) registers a global deny view when non-empty;
empty by default so no attributes are stripped until configured.

# Conflicts:
#	pkg/loop/config_test.go
Empty MetricViewsAttributeDenylist skips DefaultViews() instead of a
separate disabled flag. Env var is CL_TELEMETRY_METRIC_VIEWS_ATTRIBUTE_DENYLIST.

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	pkg/loop/config_test.go
@pkcll pkcll force-pushed the beholder-otel-metric-filter-views branch from c2bb0f6 to c0e49ea Compare July 13, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants